package com.dyn.videohub.Controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dyn.videohub.Service.UploadService;
import com.dyn.videohub.domain.Upload;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RestController
@RequestMapping("/upload")
public class UploadController {
    @Resource
    private UploadService uploadService;
    @GetMapping("/selectAll")
    public List<Upload> selectAll(){
        return uploadService.list();
    }

    //获取用户上传的视频
    @GetMapping("/getUserUpload")
    public List<Upload> userUpload(@RequestParam("userId") Long userId){
        LambdaQueryWrapper<Upload> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Upload::getUserId,userId);
        List<Upload> uploads=uploadService.list(lambdaQueryWrapper);
        return uploads;
    }
}
